<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<html>

<head>
    <meta charset="UTF-8">
    <title>页面展示</title>
    <link rel="stylesheet" href="../static/css/bootstrap.css"/>
    <link rel="stylesheet" href="main.css"/>
    <script type="text/javascript" src="../static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../static/js/bootstrap.min.js"></script>
</head>
<style>
    th {
        text-align: center;
    }

    td {
        text-align: center;
    }

    .modal.fade.in {
        top: 120px;
    }

    .formA tbody td {
    }
</style>

<body>
<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
                <span class="sr-only">切换导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#"><spring:message code="pageDisplay"/> </a>
            <span class="navbar-brand" id="userName"> admin</span>
        </div>
        <a style="float: right;margin-top: 15px;text-decoration: none;" href="/demo/logout"><spring:message
                code="dropOut"/> </a>
        <div class="collapse navbar-collapse" id="example-navbar-collapse">
            <ul class="nav navbar-nav" style="float: right;">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <spring:message code="Language"/> <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="?lang=zh_CN"><spring:message code="language.cn"/></a>
                        </li>
                        <li>
                            <a href="?lang=en_US"><spring:message code="language.en"/></a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
<div class="container">
    <div class="row">
        <form class="bs-example bs-example-form" role="form" id="info">
            <div class="row">
                <div class="col-md-2">
                    <div class="input-group">
                        <span class="input-group-addon"><spring:message code="name"/> :</span>
                        <input type="text" class="form-control" name="chineseName" id="selectName" value=""/>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="input-group">
                        <span class="input-group-addon"><spring:message code="telephoneNumber"/>:</span>
                        <input type="text" class="form-control" name="telNumber" id="selectTelNumber" value=""/>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="input-group">
                        <span class="input-group-addon"><spring:message code="account"/>:</span>
                        <input type="text" class="form-control" name="gitlabNumber" id="selectGitlabNumber" value=""/>
                    </div>
                </div>
            </div>
            <br/>
            <div class="row">
                <div class="col-md-2">
                    <div class="input-group">
                        <span class="input-group-addon"><spring:message code="credit"/>:</span>
                        <input type="text" class="form-control" name="credit" id="selectCredit" value=""/>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="input-group">
                        <span class="input-group-addon"><spring:message code="grade"/>:</span>
                        <input type="text" class="form-control" name="grade" id="selectGrade" value=""/>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="input-group">
                        <span class="input-group-addon"><spring:message code="emile"/>:</span>
                        <input type="text" class="form-control" name="email" id="selectEmail" value=""/>
                    </div>
                </div>
                <div class="col-md-2">
                    <div></div>
                    <input type="reset" class="btn btn-default" name="" id="resetBut"
                           value="<spring:message code="reset"/>"/>
                    <input type="button" class="btn btn-success" name="" id="selectBut"
                           value="<spring:message code="inquire"/>"/>
                </div>
            </div>
            <br/>
        </form>
    </div>

    <div class="row">

        <input type="button" class="btn btn-danger" name="" id="addsBtn"
               value="<spring:message code="add"/>"/>

        <input type="button" class="btn btn-info" name="" id="updateBtn"
               value="<spring:message code="modify"/>"/>

        <input type="button" class="btn btn-success" name="" id="deleteBtn"
               value="<spring:message code="delete"/>"/>

        <input type="button" class="btn btn-primary" name="" id="permissionBtn"
               value="<spring:message code="permission"/>"/>

        <input type="button" class="btn btn-default" name="" id="fileBtn"
               value="<spring:message code="sFile"/> "/>
        <input type="button" class="btn btn-default" name="" id="downloadBtn"
               value="<spring:message code="eData"/> "/>
        <input type="button" class="btn btn-default" name="" id="download1Btn"
               value="<spring:message code="eSDate"/> "/>
    </div>
    <br/>
    <div class="row table-responsive">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th><input type="checkbox" value="0" name="userId" style="font-size: 20px;"/></th>
                <th><spring:message code="id"/></th>
                <th><spring:message code="name"/></th>
                <th><spring:message code="telephoneNumber"/></th>
                <th><spring:message code="account"/></th>
                <th><spring:message code="emile"/></th>
                <th><spring:message code="credit"/></th>
                <th><spring:message code="grade"/></th>
            </tr>
            </thead>
            <tbody id="tableId">
            </tbody>
            <tr>
                <!--分页设计  -->
                <td colspan="8" align="center"><spring:message code="total"/> <span id="span1"></span><spring:message
                        code="records"/> <spring:message code="total"/><span id="span2"></span><spring:message
                        code="page"/> <spring:message code="current"/><span
                        id="span3"></span><spring:message code="page"/><br>
                    <input class="btn btn-success" type="button" onclick="first()" name="fristPage" id="button3"
                           value="<spring:message code="home" />"/>
                    <input class="btn btn-success" type="button" onclick="on()" name="previousPage" id="button1"
                           value='<spring:message code="previousPage" />'/>
                    <input class="btn btn-success" type="button" onclick="less()" name="nextPage" id="button2"
                           value='<spring:message code="nextPage" />'/>
                    <input class="btn btn-success" type="button" onclick="tail()" name="lastPage" id="button4"
                           placeholder='<spring:message code="pNumber"/> ！'
                           value='<spring:message code="lastPage" />'/>
                    <input class="" type="text" id = "Jump" name="lastPage" onkeyup="value=value.replace(/[^\d]/g,'')"
                           style="width: 26px;height: 26px;"/>
                    <input class="btn btn-success" type="button" onclick="Jump()" name="lastPage"
                           value='<spring:message code="jump" />'/>
                </td>
            </tr>
        </table>
    </div>
</div>

<!--新增查询-->
<div class="modal fade" id="adds" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="margin-top: -120px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel"><spring:message code="add"/></h4>
            </div>
            <div class="modal-body">
                <form id="addsForm">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="name"/>:</span>
                                    <input type="text" class="form-control" name="chineseName" id="addsName" value=""/>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="emile"/>:</span>
                                    <input type="text" class="form-control" name="email" id="addsEmail" value=""/>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-md-3">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="account"/>:</span>
                                    <input type="text" class="form-control" name="gitlabNumber" id="addsGitlabNumber"
                                           value=""/>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="telephoneNumber"/>:</span>
                                    <input type="text" class="form-control" name="telNumber" id="addsTelNumber" value=""
                                    />
                                </div>
                            </div>
                        </div>
                        <br/>
                </form>
                <input type="button" class="btn btn-success" name="" onclick="addss()"
                       value="<spring:message code="inquire"/>"/>
                <input type="reset" class="btn btn-default" name=""
                       value="<spring:message code="reset"/>"/>
                <div class="row">
                    <form class="formA">
                        <div>
                            <table class="table-bordered table-hover" style="width:49% ;">
                                <thead>
                                <tr>
                                    <th></th>
                                    <th><spring:message code="name"/></th>
                                    <th><spring:message code="emile"/></th>
                                </tr>
                                </thead>
                                <tbody id="addsTbody">

                                </tbody>
                            </table>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                    code="close"/></button>
            <button type="button" class="btn btn-primary" id="addBtn"><spring:message
                    code="add"/></button>
        </div>
    </div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!--新增模态框-->
<div class="modal fade" id="add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="margin-top: -120px;" id="1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title"><spring:message code="add"/></h4>
            </div>
            <div class="modal-body">
                <div class="container">
                    <div class="row">
                        <div class="col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon"><spring:message code="name"/>:</span>
                                <input type="text" class="form-control" name="chineseName" id="addName" value=""
                                       disabled="disabled"/>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon"><spring:message code="emile"/>:</span>
                                <input type="text" class="form-control" name="email" id="addEmail" value=""
                                       disabled="disabled"/>
                            </div>
                        </div>
                    </div>
                    <br/>
                    <div class="row">
                        <div class="col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon"><spring:message code="account"/>:</span>
                                <input type="text" class="form-control" name="gitlabNumber" id="addGitlabNumber"
                                       value="" disabled="disabled"/>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon"><spring:message code="telephoneNumber"/>:</span>
                                <input type="text" class="form-control" name="telNumber" id="addTelNumber" value=""
                                       disabled="disabled"/>
                            </div>
                        </div>
                    </div>
                    <br/>
                    <div class="row">
                        <div class="col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon"><spring:message code="credit"/>:</span>
                                <input type="text" class="form-control" name="credit" id="addCredit" value=""/>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon"><spring:message code="grade"/>:</span>
                                <input type="text" class="form-control" name="grade" id="addGrade" value=""/>
                            </div>
                        </div>
                    </div>
                    <br/>
                    <div class="row">
                        <form class="formA">
                            <div>
                                <table class="table-bordered table-hover" style="width:49% ;">
                                    <thead>
                                    <tr>
                                        <th><spring:message code="credit"/></th>
                                        <th><spring:message code="grade"/></th>
                                    </tr>
                                    </thead>
                                    <tbody id="addTbody">

                                    </tbody>
                                </table>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                        code="close"/></button>
                <button type="button" class="btn btn-primary" id="addsubmitbtn" onclick="save()"><spring:message
                        code="add"/></button>
            </div>

        </div>

    </div>
    <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
<!--修改权限模态框-->
<div class="modal fade" id="upId" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title"><spring:message code="modifyPermission"/></h4>
            </div>
            <form id="updateIdentityId">
                <input type="text" class="form-control" name="infoId" id="infoId1"
                       value="" style="display:none"/>
                <div class="modal-body">
                    <select name="identityId">
                        <option selected value="3">普通用户</option>
                        <option value="1">管理员</option>
                    </select>
                </div>
            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                        code="close"/></button>
                <button type="button" class="btn btn-primary" id="upIdOne" onclick="confirm('
                <spring:message code="confirmUpdate"/> ?')"><spring:message
                        code="modify"/></button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- 上传文件弹出框-->
<div class="modal fade" id="files" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title"><spring:message code="sFile"/> </h4>
            </div>
            <form id="fileFrom" enctype="multipart/form-data">
                <input type="file" accept=".xls" class="form-control" name="file" id="fileId"
                       value=""/>
                <h5 style = " color:red;"><spring:message code="uploadR"/>: </h5>
                <span style="color:red;"><spring:message code="existing"/> </span>
                <div class="modal-body">
                </div>
            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                        code="close"/></button>
                <button type="button" class="btn btn-primary" id="submat1" onclick="confirm('<spring:message code="verify"/><spring:message code="upload"/> ?')"><spring:message code="upload"/></button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!--修改模态框-->
<div class="modal fade" id="update" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="margin-top: -120px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title"><spring:message code="modify"/></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <form class="bs-example bs-example-form" role="form" id="updateForm">
                        <input type="text" class="form-control" name="infoId" id="infoId"
                               value="" style="display:none"/>
                        <div class="row">
                            <div class="col-md-offset-3 col-md-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="name"/>:</span>
                                    <input type="text" class="form-control" name="chineseName" id="updateName"
                                           value="" disabled="disabled"/>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-md-offset-3 col-md-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="emile"/>:</span>
                                    <input type="text" class="form-control" name="email" id="updateEmail" value=""
                                           disabled="disabled"/>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-md-offset-3 col-md-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="account"/>:</span>
                                    <input type="text" class="form-control" name="gitlabNumber" id="updateGitlabNumber"
                                           value=""/>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-md-offset-3 col-md-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="credit"/>:</span>
                                    <input type="text" class="form-control" name="credit" id="updateCredit" value=""/>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-md-offset-3 col-md-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="grade"/>:</span>
                                    <input type="text" class="form-control" name="grade" id="updateGrade" value=""/>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-md-offset-3 col-md-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><spring:message code="telephoneNumber"/>:</span>
                                    <input type="text" class="form-control" name="telNumber" id="updateTelNumber"
                                           value=""/>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                        code="close"/></button>
                <button type="button" class="btn btn-primary" id="updateSubmitBtn" onclick="update()"><spring:message
                        code="modify"/></button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
</div>
<!-- /.modal-dialog -->
</div>

<!--删除模态框-->
<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
                <h4><spring:message code="confirmDeletion"/></h4></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                        code="close"/></button>
                <button type="button" class="btn btn-primary" id="deletem"><spring:message code="verify"/></button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!--下载模态框-->
<div class="modal fade" id="download" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <form  id="domeFrom" name="domeFrom" action="/file/download" method="post">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4><spring:message code="download"/></h4>
            </div>
            <div class="modal-body">
                <h6><spring:message code="cDownload"/> </h6>
                <input type="hidden" name="chineseName" id ="2" value="Norway" />
                <input type="hidden" name="email" id ="3" value="Norway" />
                <input type="hidden" name="telNumber" id ="4" value="Norway" />
                <input type="hidden" name="gitlabNumber" id ="5" value="Norway" />
                <input type="hidden" name="credit" id ="7" value="Norway" />
                <input type="hidden" name="grade" id ="8" value="Norway" />
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                        code="close"/></button>
                <button type="button" class="btn btn-primary" id="downloadm" data-dismiss="modal"><spring:message code="verify"/></button>
            </div>
            </form>
        </div>

        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!--下载选择模态框-->
<div class="modal fade" id="downloadf" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <form  id="domeFromOne" name="domeFromOne" action="/file/downloadOne" method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4><spring:message code="download"/> </h4>
                </div>
                <div class="modal-body">
                    <h6><spring:message code="cDownloads"/> </h6>
                    <input type="hidden" name="dis" id ="downloads" value="Norway" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><spring:message
                            code="close"/></button>
                    <button type="button" class="btn btn-primary" id="downloadmOne" data-dismiss="modal"><spring:message code="verify"/></button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
</body>

<script type="text/javascript">
    var page;
    var size;
    var b;
    var H;
    var tailPage;

    function userInfo() {
        $.ajax({
            cache: true,
            type: "POST",
            url: "/data/userInfoTwo",
            async: false,
            error: function (request) {
                alert("Connection error:" + request.error);
            },
            success: function (r) {
                var html = "";
                var data = JSON.parse(r);
                $("#userName").text(data.chineseName);
                document.getElementById('addsName').value = data.chineseName
                document.getElementById('addsEmail').value = data.email
                document.getElementById('addsTelNumber').value = data.telNumber
                document.getElementById('addsGitlabNumber').value = data.gitlabNumber
            }
        });
    }

    $(function () {
        userInfo();
        $.ajax({
            cache: true,
            type: "POST",
            url: "/data/userInfo",
            async: false,
            error: function (request) {
                alert("Connection error:" + request.error);
            },
            success: function (r) {
                var html = "";
                var data = JSON.parse(r);
                $.each(data.list, function (n, value) {
                    html = html + '<tr>' +
                        '<td><input type="checkbox" name="check" value="' + value.infoId + '" /></td>' +
                        '<td>' + value.infoId + '</td>' +
                        '<td>' + value.chineseName + '</td>' +
                        '<td>' + value.telNumber + '</td>' +
                        '<td>' + value.gitlabNumber + '</td>' +
                        '<td>' + value.email + '</td>' +
                        '<td>' + value.credit + '</td>' +
                        '<td>' + value.grade + '</td>' +
                        '</tr>';
                })
                $("#button1").attr("disabled", true);
                page = 1;
                $("#tableId").html(html);
                $("#span1").text(data.totalRows);
                $("#span2").text(data.totalPage);
                $("#span3").text(data.pageIndex + 1);
                tailPage = data.totalPage;
                if (data.totalPage <= 1) {
                    $("#button1").attr("disabled", true);
                    $("#button2").attr("disabled", true);
                    $("#button3").attr("disabled", true);
                    $("#button4").attr("disabled", true);
                }
            }
        });
    })

    $("#permissionBtn").click(function () {
        ddd();
        if (H == 1) {
            var i = $('input[type=checkbox]:checked').length;
            if (i == 1) {
                $("#upId").modal({
                    backdrop: "static",
                    keyboard: false
                });
            } else {
                if (i < 1) {
                    alert('<spring:message code="oneData"/> ');
                } else {
                    alert('<spring:message code="onlyData"/> ');
                }
            }
        }
    })
    $("#upIdOne").click(function () {
        var a;
        $.each($('input:checkbox'), function () {
            if (this.checked) {
                a = $(this).val();
            }
        });
        document.getElementById('infoId1').value = a;
        $.ajax({
            async: false,
            type: "post",
            url: "/main/upIdentity",
            data: $('#updateIdentityId').serialize(),// 你的formid
            cache: true,
            success: function (r) {
                window.location.replace("/main/show");
            }
        })

    })
    $("#selectBut").click(function () {
        $.ajax({
            cache: true,
            type: "POST",
            url: "/data/userInfo",
            data: $('#info').serialize(),// 你的formid
            async: false,
            error: function (request) {
                alert("Connection error:" + request.error);
            },
            success: function (r) {
                var html = "";
                var data = JSON.parse(r);
                var i = 0;
                $.each(data.list, function (n, value) {
                    html = html + '<tr>' +
                        '<td><input type="checkbox" name="check" value="' + value.infoId + '" /></td>' +
                        '<td>' + value.infoId + '</td>' +
                        '<td>' + value.chineseName + '</td>' +
                        '<td>' + value.telNumber + '</td>' +
                        '<td>' + value.gitlabNumber + '</td>' +
                        '<td>' + value.email + '</td>' +
                        '<td>' + value.credit + '</td>' +
                        '<td>' + value.grade + '</td>' +
                        '</tr>';
                    i++;
                })
                page = 1;
                $("#tableId").html(html);
                $("#span1").text(data.totalRows);
                $("#span2").text(data.totalPage);
                $("#span3").text(page);
                tailPage = data.totalPage
                if (data.totalPage <= 1) {
                    $("#button1").attr("disabled", true);
                    $("#button2").attr("disabled", true);
                    $("#button3").attr("disabled", true);
                    $("#button4").attr("disabled", true);
                }else{
                    $("#button1").attr("disabled", true);
                    $("#button2").attr("disabled", false);
                    $("#button3").attr("disabled", false);
                    $("#button4").attr("disabled", false);
                }
                if(i==0){
                    hmtl = "<tr> <td style='background-color: #E6E6E6;height:200px; text-align: center;padding-top: 100px' colspan=10><h4 style='color: #A4A4A4;'><spring:message code='there'/> </h4></td></tr>"
                $("#tableId").html(hmtl);
                }
            }
        });
    })
    $("#deleteBtn").click(function () {
        aaa();
        if (H == 1) {
            if ($('input[type=checkbox]:checked').length >= 1) {
                $("#delete").modal({
                    backdrop: "static",
                    keyboard: false
                });
            } else {
                alert('<spring:message code="oneData"/> ');
            }
        }
    })
    $("#deletem").click(function () {
        var a = [];
        var i = 0;
        $.each($('table tbody tr input:checkbox'), function () {
            if (this.checked) {
                a[i] = $(this).val();
                i = i + 1;
            }
        });
        d(a);
    })
    $("#updateBtn").click(function () {
        aaa();
        if (H == 1) {
            var a;
            var i = $('input[type=checkbox]:checked').length;
            $.each($('input:checkbox'), function () {
                if (this.checked) {
                    a = $(this).val();
                }
            });
            var message = {
                infoId: a
            }
            b = a;
            if (i == 1) {
                u(message);
                $("#update").modal({
                    backdrop: "static",
                    keyboard: false
                });
            } else {
                if (i < 1) {
                    alert('<spring:message code="oneData"/> ');
                } else {
                    alert('<spring:message code="onlyData"/> ');
                }
            }
        }
    })
    $("#addsBtn").click(function () {
        aaa();
        if (H == 1) {
            $("#adds").modal({
                backdrop: "static",
                keyboard: false
            });
            addss();
        }
    })
    $("#fileBtn").click(function () {
        aaa();
        if (H == 1) {
            $("#files").modal({
                backdrop: "static",
                keyboard: false
            });
        } else {

        }
    })
    $("#submat1").click(function () {
        var formData = new FormData($('#fileFrom')[0]);
        $.ajax({
            type: 'post',
            url: '/file/upload',
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            success: function (r) {
                var data = JSON.parse(r);
                if (data.statue == 1) {
                    alert(data.message)
                    window.location.replace("/main/show");
                } else {
                    alert(data.message)
                }
            }
        })
    })
    $("#downloadBtn").click(function () {
        aaa();
        if (H == 1) {
            $("#download").modal({
                backdrop: "static",
                keyboard: false
            });
        }
    })
    $("#downloadm").click(function () {
        document.getElementById('2').value = document.getElementById('selectName').value
        document.getElementById('3').value = document.getElementById('selectEmail').value
        document.getElementById('5').value = document.getElementById('selectTelNumber').value
        document.getElementById('4').value = document.getElementById('selectGitlabNumber').value
        document.getElementById('7').value = document.getElementById('selectCredit').value
        document.getElementById('8').value = document.getElementById('selectGrade').value
            document.getElementById('domeFrom').submit();
    })
    $("#download1Btn").click(function (){
        aaa();
        var i = 0;
        $.each($('table tbody tr input:checkbox'), function () {
            if (this.checked) {
                i = i + 1;
            }
        });
        if(H==1){
            if(i>=1){
                $("#downloadf").modal({
                    backdrop: "static",
                    keyboard: false
                });
            }else{
                alert("<spring:message code="oneData"/>");
            }
        }

    })
    $("#downloadmOne").click(function () {
        var a = [];
        var i = 0;
        $.each($('table tbody tr input:checkbox'), function () {
            if (this.checked) {
                a[i] = $(this).val();
                i = i + 1;
            }
        });
        if(i>=1){
            q(a);
        }else{
            alert("<spring:message code="oneData"/>");
        }

    })
    $("#addBtn").click(function () {
        aaa();
        if (H == 1) {
            var a = $("input[name='userIds']:checked").val();
            var i = $('input[type=radio]:checked').length;
            var message = {
                infoId: a
            }
            b = a;
            if (i == 1) {
                ad(message);
                $("#add").modal({
                    backdrop: "static",
                    keyboard: false
                });
                $.ajax({
                    async: false,
                    type: "post",
                    url: "/data/addSelectUserId",
                    dataType: "json",
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(message),
                    success: function (r) {
                        var html = "";
                        $.each(r, function (n, value) {
                            html = html + '<tr>' +
                                '<td>' + value.credit + '</td>' +
                                '<td>' + value.grade + '</td>' +
                                '</tr>';
                        })
                        $("#addTbody").html(html);
                    }
                })
            } else {
                if (i < 1) {
                    alert('<spring:message code="oneData"/> ');
                } else {
                    alert('<spring:message code="onlyData"/> ');
                }
            }
        }
    })
    var $thr = $('table thead tr'); //这是获取表头的复选框

    var $checkAll = $thr.find('input');

    $checkAll.click(function (event) {
        var $tbr = $('table tbody tr');
        /*将所有行的选中状态设成全选框的选中状态*/
        $tbr.find('input').prop('checked', $(this).prop('checked'));
        /*并调整所有选中行的CSS样式*/
        if ($(this).prop('checked')) {
            $tbr.find('input').parent().parent().addClass('warning');
        } else {
            $tbr.find('input').parent().parent().removeClass('warning');
        }
        /*阻止向上冒泡，以防再次触发点击操作*/
        event.stopPropagation();
    });

    function ad(message) {
        $.ajax({
            async: false,
            type: "post",
            url: "/data/addSelect",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify(message),
            success: function (r) {
                document.getElementById('addName').value = r.data.chineseName;
                document.getElementById('addEmail').value = r.data.email;
                document.getElementById('addTelNumber').value = r.data.telNumber;
                document.getElementById('addGitlabNumber').value = r.data.gitlabNumber;
            }
        })
    }

    function u(message) {
        $.ajax({
            async: false,
            type: "post",
            url: "/data/addSelectOne",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify(message),
            success: function (r) {
                document.getElementById('updateName').value = r.data.chineseName;
                document.getElementById('updateEmail').value = r.data.email;
                document.getElementById('updateTelNumber').value = r.data.telNumber;
                document.getElementById('updateGitlabNumber').value = r.data.gitlabNumber;
                document.getElementById('updateCredit').value = r.data.credit;
                document.getElementById('updateGrade').value = r.data.grade;
            }
        })
    }

    function save() {
        var credit = document.getElementById('addCredit').value
        var grade = document.getElementById('addGrade').value
        var userId = b;
        var message = {
            credit: credit,
            grade: grade,
            userId: userId
        }
        $.ajax({
            async: false,
            type: "post",
            url: "/data/add",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify(message),
            success: function (r) {
                if (r.statue == 1) {
                    alert(r.message)
                    window.location.replace("/main/show");
                } else {
                    alert(r.message);
                }
            }
        })
    }

    function update() {
        document.getElementById('infoId').value = b;
        $.ajax({
            cache: true,
            type: "POST",
            url: "/data/updateUser",
            data: $('#updateForm').serialize(),// 你的formid
            async: false,
            error: function (request) {
                alert("Connection error:" + request.error);
            },
            success: function (r) {
                var data = JSON.parse(r);
                if (data.statue == 1) {
                    alert(data.message)
                    window.location.replace("/main/show");
                } else {
                    alert(data.message)
                }
            }
        })
    }

    function d(a) {
        var message = {
            dis: a
        }
        $.ajax({
            async: false,
            type: "post",
            url: "/main/delete",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify(message),
            success: function (r) {
                if (r.statue == 1) {
                    window.location.replace("/main/show");
                } else {
                    alert(r.message);
                }
            }
        })
    }

    function first() {
        page = 1;
        $("#button1").attr("disabled", true);
        $("#button2").attr("disabled", false);
        pagination(0, 10);
        if (tailPage == 1) {
            $("#button2").attr("disabled", true);
            $("#button1").attr("disabled", true);
        }
    }

    function tail() {
        $("#button2").attr("disabled", true);
        $("#button1").attr("disabled", false);
        page = tailPage;
        pagination(tailPage, 10);
        if (tailPage == 1) {
            $("#button2").attr("disabled", true);
            $("#button1").attr("disabled", true);
        }
    }

    function on() {
        if (page <= 2) {
            $("#button1").attr("disabled", true);
        }
        $("#button2").attr("disabled", false);
        page = page - 1;
        pagination(page, 10);

    }

    function less() {
        if (page >= tailPage - 1) {
            $("#button2").attr("disabled", true);
        }
        $("#button1").attr("disabled", false);
        page = page + 1;
        pagination(page, 10);
    }

    function Jump() {
        if(document.getElementById('Jump').value>-1){
        if (document.getElementById('Jump').value > tailPage || document.getElementById('Jump').value < 1) {
            alert("<spring:message code="pNumber"/> ");
        } else {
            if (document.getElementById('Jump').value == tailPage) {
                $("#button2").attr("disabled", true);
                $("#button1").attr("disabled", false);
                page = document.getElementById('Jump').value
                pagination(page, 10);
            } else {
                if (document.getElementById('Jump').value == 1) {
                    $("#button2").attr("disabled", false);
                    $("#button1").attr("disabled", true);
                    page = document.getElementById('Jump').value
                    pagination(page, 10);
                }
                else {
                    $("#button2").attr("disabled", false);
                    $("#button1").attr("disabled", false);
                    page = document.getElementById('Jump').value
                    pagination(page, 10);
                }
            }
        }
        if (tailPage == 1) {
            $("#button2").attr("disabled", true);
            $("#button1").attr("disabled", true);
        }
    }
    }

    function pagination(a, b) {
        var chineseName = document.getElementById('selectName').value
        var email = document.getElementById('selectEmail').value
        var telNumber = document.getElementById('selectTelNumber').value
        var gitlabNumber = document.getElementById('selectGitlabNumber').value
        var credit = document.getElementById('selectCredit').value
        var grade = document.getElementById('selectGrade').value
        var message = {
            pageIndex: a,
            limit: b,
            chineseName: chineseName,
            email: email,
            telNumber: telNumber,
            gitlabNumber: gitlabNumber,
            credit: credit,
            grade: grade
        }
        $.ajax({
            async: false,
            type: "post",
            url: "/data/userInfoOne",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify(message),
            success: function (data) {
                var html = "";
                $.each(data.list, function (n, value) {
                    html = html + '<tr>' +
                        '<td><input type="checkbox" name="check" value="' + value.infoId + '" /></td>' +
                        '<td>' + value.infoId + '</td>' +
                        '<td>' + value.chineseName + '</td>' +
                        '<td>' + value.telNumber + '</td>' +
                        '<td>' + value.gitlabNumber + '</td>' +
                        '<td>' + value.email + '</td>' +
                        '<td>' + value.credit + '</td>' +
                        '<td>' + value.grade + '</td>' +
                        '</tr>';
                })
                $("#tableId").html(html);
                $("#span1").text(data.totalRows);
                $("#span2").text(data.totalPage);
                $("#span3").text(page);
            }
        })
    }

    function aaa() {
        $.ajax({
            async: false,
            type: "post",
            url: "/data/a",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.statue == 1) {
                    H = 1;
                } else {
                    alert('<spring:message code="PermissionDenied"/> ');
                    H = 2;
                }
            }
        })
    }

    function addss() {
        $.ajax({
            cache: true,
            type: "POST",
            url: "/data/addsUser",
            data: $('#addsForm').serialize(),// 你的formid
            async: false,
            error: function (request) {
                alert("Connection error:" + request.error);
            },
            success: function (r) {
                var d = JSON.parse(r);
                var html = "";
                $.each(d.data, function (n, value) {
                    html = html + '<tr>' +
                        '<td><input type="radio" name="userIds" value="' + value.userId + '" style="font-size: 20px;"/></td>' +
                        '<td>' + value.chineseName + '</td>' +
                        '<td>' + value.email + '</td>' +
                        '</tr>';
                })
                $("#addsTbody").html(html);
            }
        })
    }

    function ddd() {
        $.ajax({
            async: false,
            type: "post",
            url: "/data/b",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.statue == 1) {
                    H = 1;
                } else {
                    alert('<spring:message code="PermissionDenied"/> ');
                    H = 2;
                }
            }
        })
    }

    //新增框成绩表单校验
    var grade = /^(^[0-9]$|^1[6-9]$|^[2-9]\d$|^1\d{1}$)|100$/;
    $("#addGrade").keyup(function () {
        if (!grade.test($("#addGrade").val()) || !credit.test($("#addCredit").val())) {
            $("#addsubmitbtn").attr("disabled", true);
        } else {
            $("#addsubmitbtn").attr("disabled", false);
        }
        if (!grade.test($("#addGrade").val())) {
            alert("成绩输入错误！");
        }
    });

    //新增框学分表单验证
    var credit = /^[0-9]$|^1[6-9]$|^[2-9]\d$|^1\d{1}$/;
    $("#addCredit").keyup(function () {
        if (!credit.test($("#addCredit").val()) || !grade.test($("#addGrade").val())) {
            $("#addsubmitbtn").attr("disabled", true);
        } else {
            $("#addsubmitbtn").attr("disabled", false);
        }
        if (!credit.test($("#addCredit").val())) {
            alert("学分输入错误！");
        }
    });

    //修改框电话号码验证
    var TelNumber = /(\d{15})|(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))|(\d{3})-(\d{4})-(\d{4})$/;
    $("#updateTelNumber").keyup(function () {
        if (!gitlabNumber1.test($("#updateGitlabNumber").val())
            || !credit.test($("#updateCredit").val())
            || !grade.test($("#updateGrade").val())
            || !TelNumber.test($("#updateTelNumber").val())
        ) {
            $("#updateSubmitBtn").attr("disabled", true);
        } else {
            $("#updateSubmitBtn").attr("disabled", false);
        }
    });

    //修改框gitlab表单验证
    var gitlabNumber1 = /^[A-Za-z_]{0,25}$/;
    $("#updateGitlabNumber").keyup(function () {
        if (!gitlabNumber1.test($("#updateGitlabNumber").val())
            || !credit.test($("#updateCredit").val())
            || !grade.test($("#updateGrade").val())
            || !TelNumber.test($("#updateTelNumber").val())
        ) {
            $("#updateSubmitBtn").attr("disabled", true);
        } else {
            $("#updateSubmitBtn").attr("disabled", false);
        }
        if (!gitlabNumber1.test($("#updateGitlabNumber").val())) {
            alert("gitlab账号输入错误！");
        }
    });

    //修改框学分验证
    $("#updateCredit").keyup(function () {
        if (!gitlabNumber1.test($("#updateGitlabNumber").val())
            || !credit.test($("#updateCredit").val())
            || !grade.test($("#updateGrade").val())
            || !TelNumber.test($("#updateTelNumber").val())
        ) {
            $("#updateSubmitBtn").attr("disabled", true);
        } else {
            $("#updateSubmitBtn").attr("disabled", false);
        }
        if (!credit.test($("#updateCredit").val())) {
            alert("学分输入错误！");
        }
    });

    //修改框成绩验证
    $("#updateGrade").keyup(function () {
        if (!gitlabNumber1.test($("#updateGitlabNumber").val())
            || !credit.test($("#updateCredit").val())
            || !grade.test($("#updateGrade").val())
            || !TelNumber.test($("#updateTelNumber").val())
        ) {
            $("#updateSubmitBtn").attr("disabled", true);
        } else {
            $("#updateSubmitBtn").attr("disabled", false);
        }
        if (!grade.test($("#updateGrade").val())) {
            alert("成绩输入错误！");
        }
    });
    function q (a){
        document.getElementById('downloads').value = a;
        document.getElementById('domeFromOne').submit();

    }

</script>
</html>